package cn.tedu._06interceptor.base.config;

import cn.tedu._06interceptor.base.interceptors.MyInterceptor1;
import cn.tedu._06interceptor.base.interceptors.MyInterceptor2;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
       /* //1.添加拦截器
        //1.1拦截所有请求
        registry.addInterceptor(new MyInterceptor1());

        //1.2拦截指定请求
        registry.addInterceptor(new MyInterceptor1())
                .addPathPatterns("/v1/users/reg","/v1/users/login");

        //1.3拦截指定的模块内所有的请求
        registry.addInterceptor(new MyInterceptor1())
                .addPathPatterns("/v1/users/**");

        //1.4排除指定的请求
        registry.addInterceptor(new MyInterceptor1())
                .addPathPatterns("/v1/users/**")
                .excludePathPatterns("/v1/users/login");*/

        // 注册多个拦截器
        registry.addInterceptor(new MyInterceptor1());
        registry.addInterceptor(new MyInterceptor2());


    }
}
